﻿Public Class MenuApplication
    Inherits OpenDelibPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim appli, libelle As String

        libelle = ""
        appli = Request.QueryString("appli")
        If appli <> "" Then libelle = ctrlMenuApplication.Initialiser(appli) 'ChargerMenu(appli)

        If Not IsPostBack Then
            Me.Master.Titre = libelle
        End If

        'If IsPostBack Then
        '    If Request.Form("__EVENTTARGET") = Me.Master.UpdatePanel.UniqueID Then
        '        ExecuterAssistant(Request.Form("__EVENTARGUMENT"))
        '    End If
        'End If

    End Sub

    'Private Sub ExecuterAssistant(codeAssistant As String)
    '    If codeAssistant = "" Then Return

    '    Using svc As New ServiceAssistant.AssistantsClient
    '        Dim params As New ServiceAssistant.AssistantParameters
    '        params.Authentication = New ServiceAssistant.AuthenticationParameters
    '        params.Authentication.Token = Tools.GetInstance.getToken
    '        params.CodeAssistant = codeAssistant

    '        Try
    '            Dim results As ServiceAssistant.OperationResult
    '            results = svc.LancerAssistant(params)
    '            If results.OK Then
    '                NotifySuccess("Opération effectuée avec succès.")
    '            Else
    '                NotifyErreur(results.ErrorMessage)
    '            End If
    '        Catch ex As Exception
    '            NotifyErreur(ex.Message)
    '        End Try
    '    End Using
    'End Sub

    'Private Sub ChargerMenu(application As String)
    '    Dim collectionMenuPerso As List(Of ServiceMenu.Menu) = Nothing

    '    Using svc As New ServiceMenu.MenuPersonnelClient()
    '        Dim params As New ServiceMenu.ParametresRecupererMenuApplication
    '        params.Authentication = New ServiceMenu.AuthenticationParameters
    '        params.Authentication.Token = Tools.GetInstance().getToken()
    '        params.Application = application
    '        params.Utilisateur = Me.Master.Utilisateur

    '        Dim res As ServiceMenu.RecupererMenuApplicationResult
    '        res = svc.RecupererMenuApplication(params)
    '        If res.OK = False Then
    '            NotifyErreur(res.ErrorMessage)
    '        ElseIf res.Menus.Count > 0 Then
    '            If Not IsPostBack Then
    '                Me.Master.Titre = res.Menus(0).Libelle
    '            End If

    '            For Each menu As ServiceMenu.ElementMenu In res.Menus(0).ElementsMenu
    '                'Création de la tile
    '                Dim divContent As New HtmlGenericControl("div")

    '                Dim imgTile As HtmlGenericControl = Nothing
    '                If menu.ImageBase64 <> "" Then
    '                    imgTile = New HtmlGenericControl("img")
    '                    imgTile.Style.Add("width", "32px")
    '                    imgTile.Style.Add("height", "32px")
    '                    imgTile.Style.Add("margin-top", "20px")
    '                    imgTile.Attributes.Add("src", "data:image/png;base64," & menu.ImageBase64)
    '                End If

    '                Dim lblLibelle As New HtmlGenericControl("div")
    '                lblLibelle.InnerText = menu.Libelle
    '                lblLibelle.Style.Add("line-height", "normal")

    '                divContent.Attributes.Add("class", "btnTuile")
    '                If imgTile IsNot Nothing Then divContent.Controls.Add(imgTile)
    '                divContent.Controls.Add(lblLibelle)

    '                If menu.Url <> "" Then
    '                    divContent.Attributes.Add("onclick", "location.href='" & menu.Url & "'")
    '                ElseIf menu.Assistant <> "" Then
    '                    divContent.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(Me.Master.UpdatePanel, menu.Assistant))
    '                End If

    '                pnlMenu.Controls.Add(divContent)
    '            Next
    '        End If
    '    End Using
    'End Sub

End Class